package com.lanju.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lanju.common.SpringUtils;
import com.lanju.entity.User;
import com.lanju.model.SAModel;
import com.lanju.service.IntroduceService;

@Controller
@RequestMapping("introduce")
public class IntroduceController {
	
	@Autowired
	IntroduceService introduceService;
	
	@RequestMapping("addIntroduce")
	@ResponseBody
	public Map<String,Object> addIntroduce(HttpServletRequest request,HttpSession session){
		Map<String, Object> param = SpringUtils.getParameterMap(request);
		SAModel saModel=(SAModel) session.getAttribute("saModel");
		param.put("userCode", saModel.getAdminCode());
		return introduceService.addIntroduce(param);
	}
	
	@RequestMapping("getIntroduceDetail")
	@ResponseBody
	public Map<String,Object> getIntroduceDetail(HttpServletRequest request){
		Map<String, Object> param = SpringUtils.getParameterMap(request);
		return introduceService.getIntroduceDetail(param);
	}
	@RequestMapping("saveMessage")
	@ResponseBody
	public Map<String,Object> saveMessage(HttpServletRequest request,HttpSession session){
		Map<String, Object> param = SpringUtils.getParameterMap(request);
		User user =(User) session.getAttribute("userModel");
		System.out.println("user="+user);
		param.put("userCode", user.getUserCode());
		param.put("userName", user.getNickName());
		return introduceService.saveMessage(param);
	}
	
	@RequestMapping(value="getMessageList",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> getMessageList(HttpServletRequest request){
		Map<String, Object> param = SpringUtils.getParameterMap(request);
		return introduceService.getMessageList(param);
	}

}
